<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>LineSupport</title>
    <link
      rel="shortcut icon"
      type="image/x-icon"
      href="/examples/public/favicon.ico"
    />
    <link rel="stylesheet" href="../css/common.css" />
  </head>

  <style>
    #app {
      width: 100%;
      height: 100%;
    }
  </style>

  <body>
    <div id="app"></div>

    <script type="module">
      import * as THREE from "three";
      import * as Vis from "../../dist/Vis.es.js";
      import { v4 as getUUid } from "uuid";

      const canvasGenerator = new Vis.CanvasGenerator({
        width: 256,
        height: 256,
      })
        .draw((ctx) => {
          ctx.textBaseline = "middle";
          ctx.textAlign = "center";

          ctx.fillStyle = "rgb(206, 42, 230)";

          ctx.font = " bold 72px 微软雅黑";
          ctx.fillText("LINE", 128, 128);
        })
        .preview();

      const engine = new Vis.ModelingEngineSupport()
        .setDom(document.getElementById("app"))
        .setSize()
        .setStats(true)
        .registerResources({
          "example.canvas": canvasGenerator.get(),
        });

      const pointLight = Vis.generateConfig("PointLight", {
        position: {
          x: 30,
          y: 50,
        },
        distance: 100,
      });

      const canvasTexture = Vis.generateConfig("CanvasTexture", {
        url: "example.canvas",
      });

      const material = Vis.generateConfig("MeshStandardMaterial", {
        map: canvasTexture.vid,
      });

      const geometry = Vis.generateConfig("BoxGeometry", {
        width: 20,
        height: 20,
        depth: 20,
        widthSegments: 10,
        heightSegments: 10,
        depthSegments: 10,
      });

      const line = Vis.generateConfig("Line", {
        material: material.vid,
        geometry: geometry.vid,
      });

      const scene = Vis.generateConfig("Scene", {
        children: [pointLight.vid, line.vid],
      });

      engine.applyConfig(
        pointLight,
        canvasTexture,
        material,
        geometry,
        line,
        scene
      );

      engine.setScene(scene.vid).play();
    </script>
  </body>
</html>
